<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:oscache="http://www.springmodules.org/schema/oscache"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd">
	


	<!-- JDBC参数配置 -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="true">
		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
		<property name="ignoreResourceNotFound" value="true" />
		<property name="locations">
			<list>
				<value>classpath:/jdbc.properties</value>
			</list>
		</property>
	</bean>

	<!-- 数据源配置 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
		<!-- 设置JDBC驱动名称 -->
		<property name="driverClass" value="${c3p0.driverClass}" />
		<!-- 设置JDBC连接URL -->
		<property name="jdbcUrl" value="${c3p0.url}" />
		<!-- 设置数据库用户名 -->
		<property name="user" value="${c3p0.user}" />
		<!-- 设置数据库密码 -->
		<property name="password" value="${c3p0.password}" />
	
		<property name="acquireIncrement" value="${c3p0.acquireIncrement}"></property>  
		<!-- 设置连连接池初始化值 -->
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}"></property>  
        <!-- 设置连接池最大空闲值 -->
        <property name="maxIdleTime" value="${c3p0.maxIdleTime}"></property>  
        <!-- 设置连接池最大值 -->
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}"></property>
        <!-- 设置连接池最小值 -->  
        <property name="minPoolSize" value="${c3p0.minPoolSize}"></property>  
      
        <property name="acquireRetryDelay" value="1000"></property>  
        <property name="acquireRetryAttempts" value="60"></property>  
        <property name="breakAfterAcquireFailure" value="false"></property>  
		
	</bean>

	<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<!-- 配置Hibernate拦截器,自动填充数据的插入、更新时间 -->
		<!-- <property name="entityInterceptor" ref="entityInterceptor" /> -->
		<property name="dataSource" ref="dataSource" />
		<property name="hibernateProperties">
			<value>
				<!-- 设置数据库方言 -->
				hibernate.dialect=${hibernate.dialect}
				<!-- 设置自动创建|更新|验证数据库表结构 -->
				hibernate.hbm2ddl.auto=false<!-- update -->
				<!-- 输出SQL语句到控制台 -->
				hibernate.show_sql=${hibernate.show_sql}
				<!-- 格式化输出到控制台的SQL语句 -->
				hibernate.format_sql=${hibernate.format_sql}
				<!-- 是否开启二级缓存 -->
				hibernate.cache.use_second_level_cache=false
				<!-- 配置二级缓存产品 -->
				hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider
				<!-- 是否开启查询缓存 -->
				hibernate.cache.use_query_cache=false
				<!-- 数据库批量查询数 -->
				hibernate.jdbc.fetch_size=50
				<!-- 数据库批量更新数 -->
				hibernate.jdbc.batch_size=30
				<!-- 可以避免一个错误Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException -->
				hibernate.temp.use_jdbc_metadata_defaults=false
			</value>
		</property>

		<property name="annotatedClasses">
			<list>
				<value>com.kof.userregister.model.User</value>
			<!-- 	<value>net.shopxx.entity.Area</value>
				<value>net.shopxx.entity.LogConfig</value>
				<value>net.shopxx.entity.Log</value>
				<value>net.shopxx.entity.Admin</value>
				<value>net.shopxx.entity.Role</value>
				<value>net.shopxx.entity.Resource</value>
				<value>net.shopxx.entity.MemberRank</value>
				<value>net.shopxx.entity.Member</value>
				<value>net.shopxx.entity.MemberAttribute</value>
				<value>net.shopxx.entity.Receiver</value>
				<value>net.shopxx.entity.ProductCategory</value>
				<value>net.shopxx.entity.Product</value>
				<value>net.shopxx.entity.ProductType</value>
				<value>net.shopxx.entity.ProductAttribute</value>
				<value>net.shopxx.entity.Brand</value>
				<value>net.shopxx.entity.Navigation</value>
				<value>net.shopxx.entity.ArticleCategory</value>
				<value>net.shopxx.entity.Article</value>
				<value>net.shopxx.entity.FriendLink</value>
				<value>net.shopxx.entity.Footer</value>
				<value>net.shopxx.entity.Agreement</value>
				<value>net.shopxx.entity.Message</value>
				<value>net.shopxx.entity.CartItem</value>
				<value>net.shopxx.entity.PaymentConfig</value>
				<value>net.shopxx.entity.Deposit</value>
				<value>net.shopxx.entity.Payment</value>
				<value>net.shopxx.entity.Refund</value>
				<value>net.shopxx.entity.Shipping</value>
				<value>net.shopxx.entity.Reship</value>
				<value>net.shopxx.entity.DeliveryType</value>
				<value>net.shopxx.entity.DeliveryCorp</value>
				<value>net.shopxx.entity.DeliveryItem</value>
				<value>net.shopxx.entity.Order</value>
				<value>net.shopxx.entity.OrderItem</value>
				<value>net.shopxx.entity.OrderLog</value>
				 -->
			</list>
		</property>
	</bean>

	<!-- 缓存配置 -->
	<!--  <oscache:config configLocation="classpath:oscache.properties" id="cacheProvider" />
	<oscache:annotations providerId="cacheProvider">
		<oscache:caching id="caching" cronExpression="0 1 * * *" refreshPeriod="86400" />
		<oscache:flushing id="flushing" />
	</oscache:annotations>
	
	<bean id="cacheManager" class="org.springmodules.cache.provider.oscache.OsCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:oscache.properties" />
    </bean>
    -->
	<!-- 设置需要进行Spring注解扫描的类包 -->
	 <context:component-scan base-package="com.kof.userregister" />

	<!-- 使用AspectJ方式配置AOP -->
	<aop:aspectj-autoproxy proxy-target-class="true" />
	<aop:config proxy-target-class="true" /> 

	<!-- 使用注解方式定义事务 -->
	<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />

	<!-- 配置事务管理器 -->
	<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

	<!-- 配置事务传播特性 -->
	<tx:advice id="transactionAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="delete*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="get*" read-only="true" />
			<tx:method name="load*" read-only="true" />
			<tx:method name="find*" read-only="true" />
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<!-- 配置哪些类的哪些方法参与事务 -->
	<aop:config>
		<aop:advisor pointcut="execution(* com.kof.userregister.service..*.*(..))" advice-ref="transactionAdvice" />
	</aop:config>

	<!-- 配置freemarkerManager -->
	<!-- <bean id="freemarkerManager" class="org.apache.struts2.views.freemarker.FreemarkerManager" /> -->

	<!-- 配置JCaptcha验证码功能 -->
<!-- 	<bean id="captchaService" class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService">
		<property name="captchaEngine">
			<bean class="net.shopxx.common.JCaptchaEngine" />
		</property> -->
		<!-- 验证码过期时间 -->
	<!-- 	<property name="minGuarantedStorageDelayInSeconds" value="600" />
	</bean> -->

	<!-- 重建索引配置 -->
	<!-- <bean id="indexBuilder" class="net.shopxx.common.CompassIndexBuilder">
		<property name="compassGps" ref="compassGps" />
		<property name="lazyTime" value="30" />
	</bean> -->
	
	<!-- SMTP邮件服务配置 -->
	<!-- <bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
		<property name="javaMailProperties">
			<props>
				<prop key="mail.smtp.auth">true</prop>
				<prop key="mail.smtp.timeout">25000</prop>-->
				<!-- SSL连接配置 -->
				<!--
				<prop key="mail.smtp.starttls.enable">true</prop>  
				<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
				-->
		<!-- 	</props>
		</property>
	</bean>
	 -->
	<!-- SMTP邮件异步发送 -->
	<!-- <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> -->
		<!-- 核心线程数 -->
		
		<!-- 	<property name="corePoolSize" value="10" /> -->
	
		<!-- 最大线程数 -->
	<!-- 	<property name="maxPoolSize" value="50" /> -->
		<!-- 最大队列数 -->
		<!-- <property name="queueCapacity" value="10000" /> -->
		<!-- 线程池维护线程所允许的空闲时间 -->
		<!-- <property name="keepAliveSeconds" value="60" />
	</bean>
 -->
</beans>